// electron 主进程
import path from 'path'
import { app, BrowserWindow, ipcMain} from 'electron'



app.whenReady().then(() => {
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    // show: true,
    // frame: false,
    // resizable: false,
    // autoHideMenuBar: true,
    titleBarStyle: 'hidden',
    titleBarOverlay: {
      color: 'rgba(0,0,0,0)',
      height: 35,
      symbolColor: 'white'
    },
    title: 'myqsl工具箱',
    icon: 'favicon.ico',
    webPreferences: {
      nodeIntegration: true, // 是否集成 Nodejs
      contextIsolation: false, // 是否启用上下文隔离
      webSecurity: false, // 是否启用同源策略
      preload: path.join(__dirname, 'preload.js')
    },
  })
  
  // win.webContents.openDevTools()
  ipcMain.handle('clons',() =>{
    win.close()
  })

  ipcMain.handle('maximize',() =>{
    !win.isMaximized() ? win.maximize()  : win.restore()
  })
  ipcMain.handle('minimize',() =>{
    if(!win.isMaximized()) win.minimize()
  })

  if (process.argv[2]) win.loadURL(process.argv[2])
  else win.loadFile('index.html')
})


